package com.android.yummycookies.component.loadingScreen;

import java.util.Timer;
import java.util.TimerTask;

import android.content.Context;
import android.os.Handler;

import com.android.yummycookies.commonInterface.IUpdatable;
import com.android.yummycookies.model.theme.Theme;

public abstract class AbstractAnimatedThemeLoadingScreen extends
		AbstractThemeLoadingScreen implements IUpdatable {

	private long fps;
	
	//NOTIFIER l'AVANCE DE L'ANIMATION
	//private Handler handlerToNotify;

	public AbstractAnimatedThemeLoadingScreen(Context context, Theme theme,
			int heightToScale, int widthToScale,
			long fps) {
		super(context, theme, heightToScale, widthToScale);
		this.fps = fps;
		thread.start();
	}

	private Thread thread = new Thread(new Runnable() {

		@Override
		public void run() {
			Timer timer = new Timer();
			timer.schedule(new TimerTask() {
				public void run() {
					update();
				}
			}, 0, fps);
		}
	});
	
	public void destroy(){
		destructionThread.start();
	}
	
	public abstract void animateDestruction();
	
	private Thread destructionThread = new Thread(new Runnable() {

		@Override
		public void run() {
			Timer timer = new Timer();
			timer.schedule(new TimerTask() {
				public void run() {
					animateDestruction();
				}
			}, 0, fps);
		}
	});

}
